<ul id="busTree" class="ztree"></ul>

<script type="text/javascript">
	var setting = {  
	        data: {  
	            simpleData: {  
	                enable: true  
	            }  
	        },
	        async: {
	            enable: true,
	            contentType: "application/json; charset=utf-8",
				dataType: "json",
	            url: "../../ztree/children",
	            autoParam:["id", "name", "level"],
	            otherParam:{"otherParam":"zTreeAsyncTest"},
	            dataFilter: filter
	        },
	        callback: {
				beforeClick: function(treeId, treeNode) {
				},
				onClick:function( event,treeId,treeNode ){
					zht = treeNode.id;
					zht_name = treeNode.name;
					global.device_data_tree_selected_id = treeNode.id;
					global.device_data_tree_selected_level = treeNode.level;
					if( showDataChart != undefined ){
						//loadDevices();
						showDataChart();
					}
				},
				onCheck:function(event,treeId,treeNode){
				}
			}
	};
	
	function filter(treeId, parentNode, childNodes) {
	    if (!childNodes.data) return null;
	    for (var i=0, l=childNodes.data.length; i<l; i++) {
	    	childNodes.data[i].name = childNodes.data[i].name.replace(/\.n/g, '.');
	    	childNodes.data[i].id = childNodes.data[i].code;
	    	childNodes.data[i].pId = childNodes.data[i].p_code;
	    	childNodes.data[i].iconSkin = childNodes.data[i].iconSkin.replace("close","docu")
	    }
	    return childNodes.data;
	}
	
	var zNodes = new Array();
	function loadTree( city_code, city_name ){
		var url = "../../ztree/city";
    	var paramMap = {};
    	paramMap.city_code = city_code;
		paramMap.city_name = city_name;
		paramMap.maxLevel = 3;
		var json_data = JSON.stringify( paramMap );
		$.ajax({
			  url: url,
			  type : 'post',
			  async : false,
			  data: json_data,
			  contentType: "application/json; charset=utf-8",
			  dataType: "json",
			  success: function(json) {
				  zNodes = json.data;
				  zTreeObj = $.fn.zTree.init( $("#busTree"), setting, zNodes );
			  }
		});
	}
	
    $(".sm-left>.tree").niceScroll({
        cursorcolor:"#999",
        cursoropacitymax:1,
        touchbehavior:false,
        cursorwidth:"6px",
        cursorborder:"0",
        cursorborderradius:"5px",
        autohidemode:false,
    })
    
    $(document).ready(function(){
    	loadTree( global.system_city_code, global.system_city_name );
	});
</script>